{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0;
        margin-top: 0
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                                                {in name='admin.type' value="1,2"} <!--超管、客服-->
                    <div class="fixed-table-toolbar" style="text-align: center;margin-bottom: 20px">
                        <h2>总金额: <span style="color: #1ab394; ">{:number_format($sum,2)}</span> 元</h2>
                    </div>
                                                {/in}

                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='state'}{else /}asdlkjasd{/present}" href="{:url('topup')}">全部</a>
                        <a class="btn btn-default btn-outline {eq name='state' value='1'}asdlkjasd{/eq}" href="{:url('topup',['state'=>1])}">已付款</a>
                        <a class="btn btn-default btn-outline {eq name='state' value='0'}asdlkjasd{/eq}" href="{:url('topup',['state'=>0])}">待付款</a>
                        <span style="float:right">
                        <a class="btn btn-default btn-outline {eq name='order' value='1'}asdlkjasd{/eq}"
                           href="{:url('topup',['order'=>'1'])}{present name='state'}/state/{$state}{/present}">默认排序</a>
                        <a class="btn btn-default btn-outline {eq name='order' value='2'}asdlkjasd{/eq}"
                           href="{:url('topup',['order'=>'2'])}{present name='state'}/state/{$state}{/present}">时间正序</a>
                        </span>
                    </div>
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="id" {php}if(input('?param.search')){if(input('param.search')=='id'){echo "selected";} }{/php}>会员ID</option>
                                        <option value="numbers" {php}if(input('?param.search')){if(input('param.search')=='numbers'){echo "selected";} }{/php}>订单号</option>
                                        <option value="name" {php}if(input('?param.search')){if(input('param.search')=='name'){echo "selected";} }{/php}>昵称</option>
                                        <option value="payer" {php}if(input('?param.search')){if(input('param.search')=='payer'){echo "selected";} }{/php}>用户标识</option>
                                    </select>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>

                                <input name="start" type="text" id="start" class="form-control layui-input" value="{present name='start'}{$start}{/present}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <input name="end" type="text" id="end" class="form-control layui-input" value="{present name='end'}{$end}{/present}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('topup')}">返回充值管理</a>
                                </div>{php}
                                }
                                {/php}
                                

                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">订单号</th>
                                    <th data-align="center">用户ID</th>
                                    <th data-align="center">用户昵称</th>
                                    <th data-align="center">价格</th>
                                    <th data-align="center">金币</th>
                                    <th data-align="center">充值方式</th>
                                    <th data-align="center">充值状态</th>
                                    <th data-align="center">用户标识</th>
                                    <th data-align="center">支付时间</th>
                                    <!-- <th data-align="center">管理</th> -->
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {php}$hide=array('0'=>'<font color="#f00">禁止</font>','1'=>'<font color="#1ab394">正常</font>','2'=>'审核','3'=>'<font color="#f00">拒绝</font>');{/php}
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td>{$v.id}</td>
                                    <td>{$v.numbers}</td>
                                    <td>{$v.fk_userid}</td>
                                    <td>{if condition='$v.name !== null'}{$v.name}{else /}<span style="color: red">已注销</span>{/if}</td>
                                    <td>{$v.price}</td>
                                    <td>{$v.money}</td>
                                    <td>{if condition="$v.type == 0"}微信{elseif condition="$v.type == 1"}支付宝{/if}</td>
                                    <td>{if condition="$v.state == 0"}待付款{elseif condition="$v.state == 1"}已付款{elseif condition="$v.state == 2"}已失效{/if}</td>
                                    <td>{$v.platform_user_id}</td>
                                    <td>{$v.addtime}</td>
                                    <!-- <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li><a onClick="del({$v.id})">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td> -->
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6">
                    <div  class="btn btn-outline btn-default" onclick="exportData()">
                        批量导出
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="exportBackData()">
                        导出为退款模板
                    </div>
                </div>
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">

$(document).ready(function(){

    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })
});

layui.use(['laydate'], function(){
    var laydate = layui.laydate;
    var form = layui.form;

    laydate.render({
        elem: '#start' //指定元素
        ,type: 'datetime'
        ,trigger: 'click'
    });

    laydate.render({
        elem: '#end' //指定元素
        ,type: 'datetime'
        ,trigger: 'click'
    });
})

function del(id){
    swal_del(id,"{:url('topupdel')}")
}

function exportData() {
    var url = "<?php echo $_SERVER['REQUEST_URI']; ?>";
    var order = "{$order}";

    var all = $(".form-horizontal").serialize();
    console.log(order,all)

    // if(!all){
    //     layer.msg("请填写需要导出的项！")
    //     return false
    // }
    window.location.href = '{:url("export/topup")}?' + all + '&url=' + url + '&order=' + order;
}
function exportBackData() {
    var url = "<?php echo $_SERVER['REQUEST_URI']; ?>";
    var order = "{$order}";

    var all = $(".form-horizontal").serialize();
    window.location.href = '{:url("export/topupBack")}?' + all + '&url=' + url + '&order=' + order;
}
 
</script>
 